package eteam.aps.systemservice.common;

import eteam.aps.common.enumeration.SortEnum;
import org.springframework.core.convert.converter.Converter;

public class StringToEnumConverter implements Converter<String, SortEnum> {
    @Override
    public SortEnum convert(String source) {
        try {
            source = source.trim();
            if (source.isEmpty()) {
                return SortEnum.Asc;
            }
            return SortEnum.valueOf(source);
        } catch (Exception e) {
            return SortEnum.Asc;
        }
    }
}